QuickOPC User's Guide and Reference
GetMultiplePropertyValues(IEasyDAClient,ServerDescriptor,DANodeDescriptor,DAPropertyDescriptor[]) Method
Example 



OpcLabs.EasyOpcClassicCore Assembly > OpcLabs.EasyOpc.DataAccess Namespace > IEasyDAClientExtension Class > GetMultiplePropertyValues Method : GetMultiplePropertyValues(IEasyDAClient,ServerDescriptor,DANodeDescriptor,DAPropertyDescriptor[]) Method
The client object that will perform the operation.
The OPC server involved in the operation.
The descriptor of the OPC node involved in the operation.
Array of OPC properties involved in the operation.
Gets values of multiple OPC properties of a specified OPC item. Gets values of multiple OPC properties, using descriptor objects for the OPC server and node, and specifying an array of property descriptors.
Syntax
'Declaration
 
<ExtensionAttribute()>
<ElementsNotNullAttribute()>
<NotNullAttribute()>
Public Overloads Shared Function GetMultiplePropertyValues( _
   ByVal client As IEasyDAClient, _
   ByVal serverDescriptor As ServerDescriptor, _
   ByVal nodeDescriptor As DANodeDescriptor, _
   ByVal propertyDescriptorArray() As DAPropertyDescriptor _
) As ValueResult()
'Usage
 
Dim client As IEasyDAClient
Dim serverDescriptor As ServerDescriptor
Dim nodeDescriptor As DANodeDescriptor
Dim propertyDescriptorArray() As DAPropertyDescriptor
Dim value() As ValueResult
 
value = IEasyDAClientExtension.GetMultiplePropertyValues(client, serverDescriptor, nodeDescriptor, propertyDescriptorArray)

Parameters

client
The client object that will perform the operation.
serverDescriptor
The OPC server involved in the operation.
nodeDescriptor
The descriptor of the OPC node involved in the operation.
propertyDescriptorArray
Array of OPC properties involved in the operation.

Return Value

The function returns an array of OpcLabs.BaseLib.OperationModel.ValueResult objects. The indices of elements in the output array are the same as those in the input array.
Exceptions
ExceptionDescription

A null reference (Nothing in Visual Basic) is passed to a method that does not accept it as a valid argument.

This is a usage error, i.e. it will never occur (the exception will not be thrown) in a correctly written program. Your code should not catch this exception.

Remarks

This method does not throw an exception in case of OPC operation failures. Instead, the eventual exception related to each property is returned in Exception property of each returned OpcLabs.BaseLib.OperationModel.ValueResult element.

 

This is a multiple-operation method. In a properly written program, it does not throw any exceptions. You should therefore not put try/catch statements or similar constructs around calls to this method. The only exceptions thrown by this method are for usage errors, i.e. when your code violates the usage contract of the method, such as passing in invalid arguments or calling the method when the state of the object does not allow it. Any operation-related errors (i.e. errors that depend on external conditions that your code cannot reliably check) are indicated in the result objects returned by the method. For more information, see Multiple-operation Methods and Do not catch any exceptions with asynchronous or multiple-operation methods.
Example

.NET

.NET

.NET

// This example shows how to get value of multiple OPC properties, and handle errors.
//
// Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
// case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
// IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your 
// code may also subscribe to the items in order to assure that they remain active.

using System;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.OperationModel;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class GetMultiplePropertyValues
    {
        public static void Main1()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ServerDescriptor serverDescriptor = "OPCLabs.KitServer.2";

            // Get the values of Timestamp and AccessRights properties of two items.
            ValueResult[] results = client.GetMultiplePropertyValues(new[]
            {
                new DAPropertyArguments(serverDescriptor, "Simulation.Random", DAPropertyDescriptor.Timestamp),
                new DAPropertyArguments(serverDescriptor, "Simulation.Random", DAPropertyDescriptor.AccessRights),
                new DAPropertyArguments(serverDescriptor, "Trends.Ramp (1 min)", DAPropertyDescriptor.Timestamp),
                new DAPropertyArguments(serverDescriptor, "Trends.Ramp (1 min)", DAPropertyDescriptor.AccessRights)
            });

            for (int i = 0; i < results.Length; i++)
            {
                ValueResult valueResult = results[i];
                if (valueResult.Exception is null)
                    Console.WriteLine($"results({i}).Value: {valueResult.Value}");
                else
                    Console.WriteLine($"results({i}).Exception.Message: {valueResult.Exception.Message}");
            }
        }
    }
}
# This example shows how to get value of multiple OPC properties, and handle errors.
#
# Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
# case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run
# IEasyDAClient.ReadItemValue.Main.vbs shortly before this example, in order to obtain better property values. Your code may
# also subscribe to the item in order to assure that it remains active.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


serverDescriptor = ServerDescriptor('OPCLabs.KitServer.2')

# Instantiate the client object.
client = EasyDAClient()

# Get the values of Timestamp and AccessRights properties of two items.
resultArray = client.GetMultiplePropertyValues([
    DAPropertyArguments(serverDescriptor, DAItemDescriptor('Simulation.Random'), DAPropertyDescriptor.Timestamp),
    DAPropertyArguments(serverDescriptor, DAItemDescriptor('Simulation.Random'), DAPropertyDescriptor.AccessRights),
    DAPropertyArguments(serverDescriptor, DAItemDescriptor('Trends.Ramp (1 min)'), DAPropertyDescriptor.Timestamp),
    DAPropertyArguments(serverDescriptor, DAItemDescriptor('Trends.Ramp (1 min)'), DAPropertyDescriptor.AccessRights),
    ])

# Display results
for i, valueResult in enumerate(resultArray):
    valueResult = resultArray[i]
    if valueResult.Exception is None:
        print('resultArray[', i, '].Value: ', valueResult.Value, sep='')
    else:
        print('resultArray[', i, '].Exception.Message: ', valueResult.Exception.Message, sep='')
# This example shows how to get value of multiple OPC properties, and handle errors.
#
# Note that some properties may not have a useful value initially (e.g. until the item is activated in a group), which also the
# case with Timestamp property as implemented by the demo server. This behavior is server-dependent, and normal. You can run 
# IEasyDAClient.ReadMultipleItemValues.Main.vbs shortly before this example, in order to obtain better property values. Your 
# code may also subscribe to the items in order to assure that they remain active.

#requires -Version 5.1
using namespace OpcLabs.EasyOpc.OperationModel
using namespace OpcLabs.EasyOpc
using namespace OpcLabs.EasyOpc.DataAccess
using namespace OpcLabs.EasyOpc.DataAccess.OperationModel

# The path below assumes that the current directory is [ProductDir]/Examples-NET/PowerShell/Windows .
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicCore.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassic.dll"
Add-Type -Path "../../../Components/Opclabs.QuickOpc/net472/OpcLabs.EasyOpcClassicComponents.dll"

# Instantiate the client object.
$client = New-Object EasyDAClient

$serverDescriptor = New-Object ServerDescriptor("OPCLabs.KitServer.2")

# Get the values of Timestamp and AccessRights properties of two items.
$results = $client.GetMultiplePropertyValues(@(
    (New-Object DAPropertyArguments($serverDescriptor, "Simulation.Random", [DAPropertyDescriptor]::Timestamp)),
    (New-Object DAPropertyArguments($serverDescriptor, "Simulation.Random", [DAPropertyDescriptor]::AccessRights)),
    (New-Object DAPropertyArguments($serverDescriptor, "Trends.Ramp (1 min)", [DAPropertyDescriptor]::Timestamp)),
    (New-Object DAPropertyArguments($serverDescriptor, "Trends.Ramp (1 min)", [DAPropertyDescriptor]::AccessRights))
    ))

for ($i = 0; $i -lt $results.Length; $i++) {
    $valueResult = $results[$i]
    if ($valueResult.Exception -eq $null) {
        Write-Host "results($($i)).Value: $($valueResult.Value)"
    }
    else {
        Write-Host "results($($i)).Exception.Message: $($valueResult.Exception.Message)"
    }
}
// This example shows how to obtain a data type of all OPC items under a branch.

using System;
using System.Linq;
using OpcLabs.BaseLib.ComInterop;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.AddressSpace;

namespace DocExamples.DataAccess._EasyDAClient
{
    partial class GetMultiplePropertyValues
    {
        public static void DataType()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();
            ServerDescriptor serverDescriptor = "OPCLabs.KitServer.2";

            // Browse for all leaves under the "Simulation" branch
            DANodeElementCollection nodeElementCollection = client.BrowseLeaves(serverDescriptor, "Simulation");

            // Create list of node descriptors, one for each leaf obtained
            DANodeDescriptor[] nodeDescriptorArray = nodeElementCollection
                .Where(element => !element.IsHint)  // filter out hint leafs that do not represent real OPC items (rare)
                .Select(element => new DANodeDescriptor(element))
                .ToArray();

            // Get the value of DataType property; it is a 16-bit signed integer
            ValueResult[] valueResultArray = client.GetMultiplePropertyValues(serverDescriptor,
                nodeDescriptorArray, DAPropertyIds.DataType);

            for (int i = 0; i < valueResultArray.Length; i++)
            {
                DANodeDescriptor nodeDescriptor = nodeDescriptorArray[i];

                // Check if there has been an error getting the property value
                ValueResult valueResult = valueResultArray[i];
                if (!(valueResult.Exception is null))
                {
                    Console.WriteLine("{0} *** Failure: {1}", nodeDescriptor.NodeId, valueResult.Exception.Message);
                    continue;
                }

                // Convert the data type to VarType
                var varType = (VarType)(short)valueResult.Value;

                // Display the obtained data type
                Console.WriteLine("{0}: {1}", nodeDescriptor.ItemId, varType);
            }
        }
    }
}
# This example shows how to obtain a data type of all OPC items under a branch.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib.ComInterop import *
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


serverDescriptor = ServerDescriptor('OPCLabs.KitServer.2')

# Instantiate the client object.
client = EasyDAClient()

# Browse for all leaves under the "Simulation" branch.
try:
    nodeElementCollection = IEasyDAClientExtension.BrowseLeaves(client, serverDescriptor, DANodeDescriptor('Simulation'))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Create list of node descriptors, one for each leaf obtained.
filteredNodeElements = filter(lambda element: not element.IsHint, nodeElementCollection)
nodeDescriptorArray = list(map(lambda element: DANodeDescriptor(element), filteredNodeElements))

# Get the value of DataType property; it is a 16-bit signed integer.
resultArray = IEasyDAClientExtension.GetMultiplePropertyValues(client,
                                                               serverDescriptor,
                                                               nodeDescriptorArray,
                                                               DAPropertyDescriptor.FromInt64(DAPropertyIds.DataType))
# Display results
for i, valueResult in enumerate(resultArray):
    nodeDescriptor = nodeDescriptorArray[i]
    # Check if there has been an error getting the property value.
    if valueResult.Exception is  None:
        # Convert the data type to VarType.
        varType = VarType(valueResult.Value)
        # Display the obtained data type.
        print(nodeDescriptor.ItemId, ': ', varType, sep='')
    else:
        print(nodeDescriptor.ItemId, ' *** Failure: ', valueResult.Exception.Message)
' This example shows how to obtain a data type of all OPC items under a branch.

Imports OpcLabs.BaseLib.ComInterop
Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess

Namespace DataAccess._EasyDAClient
    Friend Class GetMultiplePropertyValues
        Public Shared Sub DataType()
            Dim client = New EasyDAClient()
            Dim serverDescriptor As ServerDescriptor = "OPCLabs.KitServer.2"

            ' Browse for all leaves under the "Simulation" branch
            Dim nodeElementCollection = client.BrowseLeaves(serverDescriptor, "Simulation")

            ' Create list of node descriptors, one for each leaf obtained
            ' filter out hint leafs that do not represent real OPC items (rare)
            Dim nodeDescriptorArray() As DANodeDescriptor = nodeElementCollection _
                .Where(Function(element) Not element.IsHint) _
                .Select(Function(element) New DANodeDescriptor(element)) _
                .ToArray()

            ' Get the value of DataType property; it is a 16-bit signed integer
            Dim valueResultArray() As ValueResult = client.GetMultiplePropertyValues(serverDescriptor,
                    nodeDescriptorArray, DAPropertyIds.DataType)

            For i = 0 To valueResultArray.Length - 1
                Dim nodeDescriptor = nodeDescriptorArray(i)

                ' Check if there has been an error getting the property value
                Dim valueResult As ValueResult = valueResultArray(i)
                If valueResult.Exception IsNot Nothing Then
                    Console.WriteLine("{0} *** Failure: {1}", nodeDescriptor.NodeId, valueResult.Exception.Message)
                    Continue For
                End If

                ' Convert the data type to VarType
                Dim varType = CType(CShort(valueResult.Value), VarType)

                ' Display the obtained data type
                Console.WriteLine("{0}: {1}", nodeDescriptor.ItemId, varType)
            Next i
        End Sub
    End Class
End Namespace
// This example shows how to obtain a data type of all OPC XML-DA items under a branch.

using System;
using System.Linq;
using OpcLabs.BaseLib.ComInterop;
using OpcLabs.BaseLib.OperationModel;
using OpcLabs.EasyOpc;
using OpcLabs.EasyOpc.DataAccess;
using OpcLabs.EasyOpc.DataAccess.AddressSpace;

namespace DocExamples.DataAccess.Xml
{
    class GetMultiplePropertyValues
    {
        public static void DataTypeXml()
        {
            // Instantiate the client object.
            var client = new EasyDAClient();

            ServerDescriptor serverDescriptor = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx";

            // Browse for all leaves under the "Static/Analog Types" branch
            DANodeElementCollection nodeElementCollection = client.BrowseLeaves(serverDescriptor, "Static/Analog Types");

            // Create list of node descriptors, one for each leaf obtained
            DANodeDescriptor[] nodeDescriptorArray = nodeElementCollection
                .Where(element => !element.IsHint)  // filter out hint leafs that do not represent real OPC items (rare)
                .Select(element => new DANodeDescriptor(element))
                .ToArray();

            // Get the value of DataType property; it is a 16-bit signed integer
            ValueResult[] valueResultArray = client.GetMultiplePropertyValues(serverDescriptor,
                nodeDescriptorArray, DAPropertyIds.DataType);

            for (int i = 0; i < valueResultArray.Length; i++)
            {
                DANodeDescriptor nodeDescriptor = nodeDescriptorArray[i];

                // Check if there has been an error getting the property value
                ValueResult valueResult = valueResultArray[i];
                if (!(valueResult.Exception is null))
                {
                    Console.WriteLine("{0} *** Failure: {1}", nodeDescriptor.NodeId, valueResult.Exception.Message);
                    continue;
                }

                // Convert the data type to VarType
                var varType = (VarType)(short)valueResult.Value;

                // Display the obtained data type
                Console.WriteLine("{0}: {1}", nodeDescriptor.ItemId, varType);
            }
        }
    }
}
# This example shows how to obtain a data type of all OPC XML-DA items under a branch.

# The QuickOPC package is needed. Install it using "pip install opclabs_quickopc".
import opclabs_quickopc

# Import .NET namespaces.
from OpcLabs.BaseLib.ComInterop import *
from OpcLabs.EasyOpc import *
from OpcLabs.EasyOpc.DataAccess import *
from OpcLabs.EasyOpc.DataAccess.OperationModel import *
from OpcLabs.EasyOpc.OperationModel import *


serverDescriptor = ServerDescriptor('http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx')

# Instantiate the client object.
client = EasyDAClient()

# Browse for all leaves under the "Static/Analog Types" branch
try:
    nodeElementCollection = IEasyDAClientExtension.BrowseLeaves(client,
                                                                serverDescriptor,
                                                                DANodeDescriptor('Static/Analog Types'))
except OpcException as opcException:
    print('*** Failure: ' + opcException.GetBaseException().Message)
    exit()

# Create list of node descriptors, one for each leaf obtained.
filteredNodeElements = filter(lambda element: not element.IsHint, nodeElementCollection)
nodeDescriptorArray = list(map(lambda element: DANodeDescriptor(element), filteredNodeElements))

# Get the value of DataType property; it is a 16-bit signed integer.
resultArray = IEasyDAClientExtension.GetMultiplePropertyValues(client,
                                                               serverDescriptor,
                                                               nodeDescriptorArray,
                                                               DAPropertyDescriptor.FromInt64(DAPropertyIds.DataType))
# Display results
for i, valueResult in enumerate(resultArray):
    nodeDescriptor = nodeDescriptorArray[i]
    # Check if there has been an error getting the property value.
    if valueResult.Exception is  None:
        # Convert the data type to VarType.
        varType = VarType(valueResult.Value)
        # Display the obtained data type.
        print(nodeDescriptor.ItemId, ': ', varType, sep='')
    else:
        print(nodeDescriptor.ItemId, ' *** Failure: ', valueResult.Exception.Message)

print()
print('Finished')
' This example shows how to obtain a data type of all OPC XML-DA items under a branch.

Imports OpcLabs.BaseLib.ComInterop
Imports OpcLabs.BaseLib.OperationModel
Imports OpcLabs.EasyOpc
Imports OpcLabs.EasyOpc.DataAccess

Namespace DataAccess.Xml
    Friend Class GetMultiplePropertyValues
        Public Shared Sub DataTypeXml()
            Dim client = New EasyDAClient()
            Dim serverDescriptor As ServerDescriptor = "http://opcxml.demo-this.com/XmlDaSampleServer/Service.asmx"

            ' Browse for all leaves under the "Simulation" branch
            Dim nodeElementCollection = client.BrowseLeaves(serverDescriptor, "Static/Analog Types")

            ' Create list of node descriptors, one for each leaf obtained
            ' filter out hint leafs that do not represent real OPC items (rare)
            Dim nodeDescriptorArray() As DANodeDescriptor = nodeElementCollection _
                .Where(Function(element) Not element.IsHint) _
                .Select(Function(element) New DANodeDescriptor(element)) _
                .ToArray()

            ' Get the value of DataType property; it is a 16-bit signed integer
            Dim valueResultArray() As ValueResult = client.GetMultiplePropertyValues(serverDescriptor,
                    nodeDescriptorArray, DAPropertyIds.DataType)

            For i = 0 To valueResultArray.Length - 1
                Dim nodeDescriptor = nodeDescriptorArray(i)

                ' Check if there has been an error getting the property value
                Dim valueResult As ValueResult = valueResultArray(i)
                If valueResult.Exception IsNot Nothing Then
                    Console.WriteLine("{0} *** Failure: {1}", nodeDescriptor.NodeId, valueResult.Exception.Message)
                    Continue For
                End If

                ' Convert the data type to VarType
                Dim varType = CType(CShort(valueResult.Value), VarType)

                ' Display the obtained data type
                Console.WriteLine("{0}: {1}", nodeDescriptor.ItemId, varType)
            Next i
        End Sub
    End Class
End Namespace
Requirements

Target Platforms: .NET Framework: Windows 10 (selected versions), Windows 11 (selected versions), Windows Server 2016, Windows Server 2022; .NET: Linux, macOS, Microsoft Windows

See Also